<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>slider滑块</title>
 <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
  <link rel="stylesheet" href="../style/weui.css"/>
  <link rel="stylesheet" href="../style/weui2.css"/>
  <link rel="stylesheet" href="../style/weui3.css"/>
      <script src="../zepto.min.js"></script>
      <script>
  $(function(){
        var $sliderTrack = $('#sliderTrack'),
            $sliderHandler = $('#sliderHandler'),
            $sliderValue = $('#sliderValue');

        var totalLen = $('#sliderInner').width(),
            startLeft = 0,
            startX = 0;

        $sliderHandler
            .on('touchstart', function (e) {
                startLeft = parseInt($sliderHandler.css('left')) * totalLen / 100;
                startX = e.changedTouches[0].clientX;
            })
            .on('touchmove', function(e){
                var dist = startLeft + e.changedTouches[0].clientX - startX,
                    percent;
                dist = dist < 0 ? 0 : dist > totalLen ? totalLen : dist;
                percent =  parseInt(dist / totalLen * 100);
                $sliderTrack.css('width', percent + '%');
                $sliderHandler.css('left', percent + '%');
                $sliderValue.text(percent);

                e.preventDefault();
            })
        ;
	  
	  });    
      
      </script>
</head>

<body ontouchstart class="page-bg">
<div class="page-hd">
        <h1 class="page-hd-title">
            slider
        </h1>
        <p class="page-hd-desc">滑块的js不在核心</p>
    </div>
    
    <div class="page-bd">
    
        <div class="weui-slider">
            <div class="weui-slider-inner">
                <div style="width: 10%;" class="weui-slider-track"></div>
                <div style="left: 10%;" class="weui-slider-handler"></div>
            </div>
        </div>
        
        <br>
        
        <div class="weui-slider-box">
            <div class="weui-slider">
                <div id="sliderInner" class="weui-slider-inner">
                    <div id="sliderTrack" style="width: 50%;" class="weui-slider-track"></div>
                    <div id="sliderHandler" style="left: 50%;" class="weui-slider-handler"></div>
                </div>
            </div>
            <div id="sliderValue" class="weui-slider-box-value">50</div>
        </div>
        
        
    </div>
</body>
</html>
